import { defineStore } from 'pinia'
import { ref } from 'vue'
import type { UserInfo } from '../types/user'

export const useUserStore = defineStore(
  'user',
  () => {
    const token = ref('')
    const userInfo = ref({} as UserInfo)

    // 存储token
    const setToken = (val: string) => {
      token.value = val
    }

    // 用户登录信息
    const setUserInfo = (val: UserInfo) => {
      userInfo.value = val
    }

    // 语言国际化

    return {
      token,
      userInfo,
      setToken,
      setUserInfo
    }
  },
  {
    persist: true
  }
)
